#include <memory>
#include <string>
#include <fuzzer/FuzzedDataProvider.h>

#include <vmsvga_include/svga_reg.h>

#define BASE_SIZE 1024

uint32_t kCommandArray[] = {
    SVGA_CMD_INVALID_CMD           ,
    SVGA_CMD_UPDATE                ,
    SVGA_CMD_RECT_COPY             ,
    SVGA_CMD_RECT_ROP_COPY         ,
    SVGA_CMD_DEFINE_CURSOR         ,
    SVGA_CMD_DEFINE_ALPHA_CURSOR   ,
    SVGA_CMD_UPDATE_VERBOSE        ,
    SVGA_CMD_FRONT_ROP_FILL        ,
    SVGA_CMD_FENCE                 ,
    SVGA_CMD_ESCAPE                ,
    SVGA_CMD_DEFINE_SCREEN         ,
    SVGA_CMD_DESTROY_SCREEN        ,
    SVGA_CMD_DEFINE_GMRFB          ,
    SVGA_CMD_BLIT_GMRFB_TO_SCREEN  ,
    SVGA_CMD_BLIT_SCREEN_TO_GMRFB  ,
    SVGA_CMD_ANNOTATION_FILL       ,
    SVGA_CMD_ANNOTATION_COPY       ,
    SVGA_CMD_DEFINE_GMR2           ,
    SVGA_CMD_REMAP_GMR2            ,
    SVGA_CMD_DEAD                  ,
    SVGA_CMD_DEAD_2                ,
    SVGA_CMD_NOP                   ,
    SVGA_CMD_NOP_ERROR             ,
    SVGA_3D_CMD_SURFACE_DEFINE                             ,
    SVGA_3D_CMD_SURFACE_DESTROY                            ,
    SVGA_3D_CMD_SURFACE_COPY                               ,
    SVGA_3D_CMD_SURFACE_STRETCHBLT                         ,
    SVGA_3D_CMD_SURFACE_DMA                                ,
    SVGA_3D_CMD_CONTEXT_DEFINE                             ,
    SVGA_3D_CMD_CONTEXT_DESTROY                            ,
    SVGA_3D_CMD_SETTRANSFORM                               ,
    SVGA_3D_CMD_SETZRANGE                                  ,
    SVGA_3D_CMD_SETRENDERSTATE                             ,
    SVGA_3D_CMD_SETRENDERTARGET                            ,
    SVGA_3D_CMD_SETTEXTURESTATE                            ,
    SVGA_3D_CMD_SETMATERIAL                                ,
    SVGA_3D_CMD_SETLIGHTDATA                               ,
    SVGA_3D_CMD_SETLIGHTENABLED                            ,
    SVGA_3D_CMD_SETVIEWPORT                                ,
    SVGA_3D_CMD_SETCLIPPLANE                               ,
    SVGA_3D_CMD_CLEAR                                      ,
    SVGA_3D_CMD_PRESENT                                    ,
    SVGA_3D_CMD_SHADER_DEFINE                              ,
    SVGA_3D_CMD_SHADER_DESTROY                             ,
    SVGA_3D_CMD_SET_SHADER                                 ,
    SVGA_3D_CMD_SET_SHADER_CONST                           ,
    SVGA_3D_CMD_DRAW_PRIMITIVES                            ,
    SVGA_3D_CMD_SETSCISSORRECT                             ,
    SVGA_3D_CMD_BEGIN_QUERY                                ,
    SVGA_3D_CMD_END_QUERY                                  ,
    SVGA_3D_CMD_WAIT_FOR_QUERY                             ,
    SVGA_3D_CMD_PRESENT_READBACK                           ,
    SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN                     ,
    SVGA_3D_CMD_SURFACE_DEFINE_V2                          ,
    SVGA_3D_CMD_GENERATE_MIPMAPS                           ,
    SVGA_3D_CMD_DEAD4                                      ,
    SVGA_3D_CMD_DEAD5                                      ,
    SVGA_3D_CMD_DEAD6                                      ,
    SVGA_3D_CMD_DEAD7                                      ,
    SVGA_3D_CMD_DEAD8                                      ,
    SVGA_3D_CMD_DEAD9                                      ,
    SVGA_3D_CMD_DEAD10                                     ,
    SVGA_3D_CMD_DEAD11                                     ,
    SVGA_3D_CMD_ACTIVATE_SURFACE                           ,
    SVGA_3D_CMD_DEACTIVATE_SURFACE                         ,
    SVGA_3D_CMD_SCREEN_DMA                                 ,
    SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION       ,
    SVGA_3D_CMD_DEAD2                                      ,
    SVGA_3D_CMD_DEAD12                                     ,
    SVGA_3D_CMD_DEAD13                                     ,
    SVGA_3D_CMD_DEAD14                                     ,
    SVGA_3D_CMD_DEAD15                                     ,
    SVGA_3D_CMD_DEAD16                                     ,
    SVGA_3D_CMD_DEAD17                                     ,
    SVGA_3D_CMD_SET_OTABLE_BASE                            ,
    SVGA_3D_CMD_READBACK_OTABLE                            ,
    SVGA_3D_CMD_DEFINE_GB_MOB                              ,
    SVGA_3D_CMD_DESTROY_GB_MOB                             ,
    SVGA_3D_CMD_DEAD3                                      ,
    SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING                      ,
    SVGA_3D_CMD_DEFINE_GB_SURFACE                          ,
    SVGA_3D_CMD_DESTROY_GB_SURFACE                         ,
    SVGA_3D_CMD_BIND_GB_SURFACE                            ,
    SVGA_3D_CMD_COND_BIND_GB_SURFACE                       ,
    SVGA_3D_CMD_UPDATE_GB_IMAGE                            ,
    SVGA_3D_CMD_UPDATE_GB_SURFACE                          ,
    SVGA_3D_CMD_READBACK_GB_IMAGE                          ,
    SVGA_3D_CMD_READBACK_GB_SURFACE                        ,
    SVGA_3D_CMD_INVALIDATE_GB_IMAGE                        ,
    SVGA_3D_CMD_INVALIDATE_GB_SURFACE                      ,
    SVGA_3D_CMD_DEFINE_GB_CONTEXT                          ,
    SVGA_3D_CMD_DESTROY_GB_CONTEXT                         ,
    SVGA_3D_CMD_BIND_GB_CONTEXT                            ,
    SVGA_3D_CMD_READBACK_GB_CONTEXT                        ,
    SVGA_3D_CMD_INVALIDATE_GB_CONTEXT                      ,
    SVGA_3D_CMD_DEFINE_GB_SHADER                           ,
    SVGA_3D_CMD_DESTROY_GB_SHADER                          ,
    SVGA_3D_CMD_BIND_GB_SHADER                             ,
    SVGA_3D_CMD_SET_OTABLE_BASE64                          ,
    SVGA_3D_CMD_BEGIN_GB_QUERY                             ,
    SVGA_3D_CMD_END_GB_QUERY                               ,
    SVGA_3D_CMD_WAIT_FOR_GB_QUERY                          ,
    SVGA_3D_CMD_NOP                                        ,
    SVGA_3D_CMD_ENABLE_GART                                ,
    SVGA_3D_CMD_DISABLE_GART                               ,
    SVGA_3D_CMD_MAP_MOB_INTO_GART                          ,
    SVGA_3D_CMD_UNMAP_GART_RANGE                           ,
    SVGA_3D_CMD_DEFINE_GB_SCREENTARGET                     ,
    SVGA_3D_CMD_DESTROY_GB_SCREENTARGET                    ,
    SVGA_3D_CMD_BIND_GB_SCREENTARGET                       ,
    SVGA_3D_CMD_UPDATE_GB_SCREENTARGET                     ,
    SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL                  ,
    SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL                ,
    SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE                 ,
    SVGA_3D_CMD_GB_SCREEN_DMA                              ,
    SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH                 ,
    SVGA_3D_CMD_GB_MOB_FENCE                               ,
    SVGA_3D_CMD_DEFINE_GB_SURFACE_V2                       ,
    SVGA_3D_CMD_DEFINE_GB_MOB64                            ,
    SVGA_3D_CMD_REDEFINE_GB_MOB64                          ,
    SVGA_3D_CMD_NOP_ERROR                                  ,
    SVGA_3D_CMD_SET_VERTEX_STREAMS                         ,
    SVGA_3D_CMD_SET_VERTEX_DECLS                           ,
    SVGA_3D_CMD_SET_VERTEX_DIVISORS                        ,
    SVGA_3D_CMD_DRAW                                       ,
   SVGA_3D_CMD_DX_DEFINE_CONTEXT                          ,
   SVGA_3D_CMD_DX_DESTROY_CONTEXT                         ,
   SVGA_3D_CMD_DX_BIND_CONTEXT                            ,
   SVGA_3D_CMD_DX_READBACK_CONTEXT                        ,
   SVGA_3D_CMD_DX_INVALIDATE_CONTEXT                      ,
   SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER              ,
   SVGA_3D_CMD_DX_SET_SHADER_RESOURCES                    ,
   SVGA_3D_CMD_DX_SET_SHADER                              ,
   SVGA_3D_CMD_DX_SET_SAMPLERS                            ,
   SVGA_3D_CMD_DX_DRAW                                    ,
   SVGA_3D_CMD_DX_DRAW_INDEXED                            ,
   SVGA_3D_CMD_DX_DRAW_INSTANCED                          ,
   SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED                  ,
   SVGA_3D_CMD_DX_DRAW_AUTO                               ,
   SVGA_3D_CMD_DX_SET_INPUT_LAYOUT                        ,
   SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS                      ,
   SVGA_3D_CMD_DX_SET_INDEX_BUFFER                        ,
   SVGA_3D_CMD_DX_SET_TOPOLOGY                            ,
   SVGA_3D_CMD_DX_SET_RENDERTARGETS                       ,
   SVGA_3D_CMD_DX_SET_BLEND_STATE                         ,
   SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE                  ,
   SVGA_3D_CMD_DX_SET_RASTERIZER_STATE                    ,
   SVGA_3D_CMD_DX_DEFINE_QUERY                            ,
   SVGA_3D_CMD_DX_DESTROY_QUERY                           ,
   SVGA_3D_CMD_DX_BIND_QUERY                              ,
   SVGA_3D_CMD_DX_SET_QUERY_OFFSET                        ,
   SVGA_3D_CMD_DX_BEGIN_QUERY                             ,
   SVGA_3D_CMD_DX_END_QUERY                               ,
   SVGA_3D_CMD_DX_READBACK_QUERY                          ,
   SVGA_3D_CMD_DX_SET_PREDICATION                         ,
   SVGA_3D_CMD_DX_SET_SOTARGETS                           ,
   SVGA_3D_CMD_DX_SET_VIEWPORTS                           ,
   SVGA_3D_CMD_DX_SET_SCISSORRECTS                        ,
   SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW                 ,
   SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW                 ,
   SVGA_3D_CMD_DX_PRED_COPY_REGION                        ,
   SVGA_3D_CMD_DX_PRED_COPY                               ,
   SVGA_3D_CMD_DX_PRESENTBLT                              ,
   SVGA_3D_CMD_DX_GENMIPS                                 ,
   SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE                      ,
   SVGA_3D_CMD_DX_READBACK_SUBRESOURCE                    ,
   SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE                  ,
   SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW              ,
   SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW             ,
   SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW                ,
   SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW               ,
   SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW                ,
   SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW               ,
   SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT                    ,
   SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT                   ,
   SVGA_3D_CMD_DX_DEFINE_BLEND_STATE                      ,
   SVGA_3D_CMD_DX_DESTROY_BLEND_STATE                     ,
   SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE               ,
   SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE              ,
   SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE                 ,
   SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE                ,
   SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE                    ,
   SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE                   ,
   SVGA_3D_CMD_DX_DEFINE_SHADER                           ,
   SVGA_3D_CMD_DX_DESTROY_SHADER                          ,
   SVGA_3D_CMD_DX_BIND_SHADER                             ,
   SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT                     ,
   SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT                    ,
   SVGA_3D_CMD_DX_SET_STREAMOUTPUT                        ,
   SVGA_3D_CMD_DX_SET_COTABLE                             ,
   SVGA_3D_CMD_DX_READBACK_COTABLE                        ,
   SVGA_3D_CMD_DX_BUFFER_COPY                             ,
   SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER                    ,
   SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK               ,
   SVGA_3D_CMD_DX_MOVE_QUERY                              ,
   SVGA_3D_CMD_DX_BIND_ALL_QUERY                          ,
   SVGA_3D_CMD_DX_READBACK_ALL_QUERY                      ,
   SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER               ,
   SVGA_3D_CMD_DX_MOB_FENCE_64                            ,
   SVGA_3D_CMD_DX_BIND_ALL_SHADER                         ,
   SVGA_3D_CMD_DX_HINT                                    ,
   SVGA_3D_CMD_DX_BUFFER_UPDATE                           ,
   SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET           ,
   SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET           ,
   SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET           ,
   SVGA_3D_CMD_DX_SET_HS_CONSTANT_BUFFER_OFFSET           ,
   SVGA_3D_CMD_DX_SET_DS_CONSTANT_BUFFER_OFFSET           ,
   SVGA_3D_CMD_DX_SET_CS_CONSTANT_BUFFER_OFFSET           ,
   SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER                    ,
   SVGA_3D_CMD_DX_MAX                                     ,
   SVGA_3D_CMD_SCREEN_COPY                                ,
   SVGA_3D_CMD_RESERVED1                                  ,
   SVGA_3D_CMD_RESERVED2                                  ,
   SVGA_3D_CMD_RESERVED3                                  ,
   SVGA_3D_CMD_RESERVED4                                  ,
   SVGA_3D_CMD_RESERVED5                                  ,
   SVGA_3D_CMD_RESERVED6                                  ,
   SVGA_3D_CMD_RESERVED7                                  ,
   SVGA_3D_CMD_RESERVED8                                  ,
   SVGA_3D_CMD_GROW_OTABLE                                ,
   SVGA_3D_CMD_DX_GROW_COTABLE                            ,
   SVGA_3D_CMD_INTRA_SURFACE_COPY                         ,
   SVGA_3D_CMD_DEFINE_GB_SURFACE_V3                       ,
   SVGA_3D_CMD_DX_RESOLVE_COPY                            ,
   SVGA_3D_CMD_DX_PRED_RESOLVE_COPY                       ,
   SVGA_3D_CMD_DX_PRED_CONVERT_REGION                     ,
   SVGA_3D_CMD_DX_PRED_CONVERT                            ,
   SVGA_3D_CMD_WHOLE_SURFACE_COPY                         ,
   SVGA_3D_CMD_DX_DEFINE_UA_VIEW                          ,
   SVGA_3D_CMD_DX_DESTROY_UA_VIEW                         ,
   SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT                      ,
   SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT                     ,
   SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT                    ,
   SVGA_3D_CMD_DX_SET_UA_VIEWS                            ,
   SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT         ,
   SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT                 ,
   SVGA_3D_CMD_DX_DISPATCH                                ,
   SVGA_3D_CMD_DX_DISPATCH_INDIRECT                       ,
   SVGA_3D_CMD_WRITE_ZERO_SURFACE                         ,
   SVGA_3D_CMD_HINT_ZERO_SURFACE                          ,
   SVGA_3D_CMD_DX_TRANSFER_TO_BUFFER                      ,
   SVGA_3D_CMD_DX_SET_STRUCTURE_COUNT                     ,
   SVGA_3D_CMD_LOGICOPS_BITBLT                            ,
   SVGA_3D_CMD_LOGICOPS_TRANSBLT                          ,
   SVGA_3D_CMD_LOGICOPS_STRETCHBLT                        ,
   SVGA_3D_CMD_LOGICOPS_COLORFILL                         ,
   SVGA_3D_CMD_LOGICOPS_ALPHABLEND                        ,
   SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND                    ,
   SVGA_3D_CMD_RESERVED2_1                                ,
   SVGA_3D_CMD_RESERVED2_2                                ,
   SVGA_3D_CMD_DEFINE_GB_SURFACE_V4                       ,
   SVGA_3D_CMD_DX_SET_CS_UA_VIEWS                         ,
   SVGA_3D_CMD_DX_SET_MIN_LOD                             ,
   SVGA_3D_CMD_RESERVED2_3                                ,
   SVGA_3D_CMD_RESERVED2_4                                ,
   SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2             ,
   SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB            ,
   SVGA_3D_CMD_DX_SET_SHADER_IFACE                        ,
   SVGA_3D_CMD_DX_BIND_STREAMOUTPUT                       ,
   SVGA_3D_CMD_SURFACE_STRETCHBLT_NON_MS_TO_MS            ,
   SVGA_3D_CMD_DX_BIND_SHADER_IFACE                       ,
   SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE_V2              ,
   VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR                ,
   VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER_OUTPUT_VIEW      ,
   VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER                  ,
   VBSVGA_3D_CMD_DX_VIDEO_DECODER_BEGIN_FRAME             ,
   VBSVGA_3D_CMD_DX_VIDEO_DECODER_SUBMIT_BUFFERS          ,
   VBSVGA_3D_CMD_DX_VIDEO_DECODER_END_FRAME               ,
   VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_INPUT_VIEW     ,
   VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_OUTPUT_VIEW    ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_BLT                   ,
   VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER                 ,
   VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER_OUTPUT_VIEW     ,
   VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR               ,
   VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_INPUT_VIEW    ,
   VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_OUTPUT_VIEW   ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_TARGET_RECT ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_BACKGROUND_COLOR ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_COLOR_SPACE ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_ALPHA_FILL_MODE ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_CONSTRICTION ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_STEREO_MODE ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FRAME_FORMAT ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_COLOR_SPACE ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_OUTPUT_RATE ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_SOURCE_RECT ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_DEST_RECT  ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ALPHA      ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PALETTE    ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PIXEL_ASPECT_RATIO ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_LUMA_KEY   ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_STEREO_FORMAT ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_AUTO_PROCESSING_MODE ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FILTER     ,
   VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ROTATION   ,
   VBSVGA_3D_CMD_DX_GET_VIDEO_CAPABILITY                  ,
   VBSVGA_3D_CMD_DX_CLEAR_RTV                             ,
   VBSVGA_3D_CMD_DX_CLEAR_UAV                             ,
   VBSVGA_3D_CMD_DX_CLEAR_VDOV                            ,
   VBSVGA_3D_CMD_DX_CLEAR_VPIV                            ,
   VBSVGA_3D_CMD_DX_CLEAR_VPOV                            
};

uint8_t* InternalCommandAlloc(FuzzedDataProvider *fdp, uint32_t& total_length, uint32_t& pos, uint8_t* result, void* cmd, uint32_t cmd_size, uint32_t cmdId, bool is_3d) {
    total_length += cmd_size + sizeof(uint32_t);

    if (is_3d)
        total_length += sizeof(uint32_t);

    if (total_length > BASE_SIZE)
        result = (uint8_t*)realloc(result, total_length);

    if (result == nullptr) return nullptr;

    *(uint32_t*)(result + pos) = cmdId;
    pos += sizeof(uint32_t);

    if (is_3d){
        *(uint32_t*)(result + pos) = cmd_size;
        pos += sizeof(uint32_t);
    }

    memset(cmd, 0, cmd_size);
    std::vector<uint8_t> cmd_bytes = fdp->ConsumeBytes<uint8_t>(cmd_size);

    if (cmd_bytes.data() != nullptr) {
        memcpy(cmd, cmd_bytes.data(), cmd_bytes.size());
        memcpy(result + pos, cmd, cmd_size);
    }
    pos += cmd_size;
    return result;
}

uint8_t* AllocateRandomCommands(FuzzedDataProvider *fdp, uint32_t& commands_length) {
    uint8_t *result = (uint8_t*)malloc(BASE_SIZE);
    uint32_t pos = 0;
    //uint8_t command_count = fdp->ConsumeIntegral<uint8_t>();
    //Experiment with only one command at a time.
    uint8_t command_count = 1;
    if (command_count == 0) return nullptr;
    uint32_t total_length = 0;
    while (command_count > 0) {
        command_count--;
        uint32_t cmdId = fdp->ConsumeIntegral<uint32_t>() % (sizeof(kCommandArray)/sizeof(uint32_t));
        cmdId = kCommandArray[cmdId];
        switch (cmdId) {
            case SVGA_CMD_INVALID_CMD: 
                {
                    continue;
                }

            case SVGA_CMD_FENCE:
                {
                    SVGAFifoCmdFence cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdFence);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_UPDATE:
                {
                    SVGAFifoCmdUpdate cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdUpdate);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_UPDATE_VERBOSE:
                {
                    SVGAFifoCmdUpdateVerbose cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdUpdateVerbose);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_DEFINE_CURSOR:
                {
                    SVGAFifoCmdDefineCursor cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdDefineCursor);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_DEFINE_ALPHA_CURSOR:
                {
                    SVGAFifoCmdDefineAlphaCursor cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdDefineAlphaCursor);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_MOVE_CURSOR:
                {
                    SVGAFifoCmdMoveCursor cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdMoveCursor);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_CMD_DISPLAY_CURSOR:
                {
                    SVGAFifoCmdDisplayCursor cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdDisplayCursor);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_RECT_FILL:
                {
                    SVGAFifoCmdRectFill cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdRectFill);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_RECT_COPY:
                {
                    SVGAFifoCmdRectCopy cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdRectCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_RECT_ROP_COPY:
                {
                    SVGAFifoCmdRectRopCopy cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdRectRopCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_ESCAPE:
                {
                    /* Followed by 'size' bytes of data. */
                    SVGAFifoCmdEscape cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdEscape);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }
            case SVGA_CMD_DEFINE_GMR2:
                {
                    SVGAFifoCmdDefineGMR2 cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdDefineGMR2);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_REMAP_GMR2:
                {
                    SVGAFifoCmdRemapGMR2 cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdRemapGMR2);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }
            case SVGA_CMD_DEFINE_SCREEN:
                {
                    SVGAFifoCmdDefineScreen cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdDefineScreen);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_DESTROY_SCREEN:
                {
                    SVGAFifoCmdDestroyScreen cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdDestroyScreen);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_DEFINE_GMRFB:
                {
                    SVGAFifoCmdDefineGMRFB cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdDefineGMRFB);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_BLIT_GMRFB_TO_SCREEN:
                {
                    SVGAFifoCmdBlitGMRFBToScreen cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdBlitGMRFBToScreen);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_BLIT_SCREEN_TO_GMRFB:
                {
                    SVGAFifoCmdBlitScreenToGMRFB cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdBlitScreenToGMRFB);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_ANNOTATION_FILL:
                {
                    SVGAFifoCmdAnnotationFill cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdAnnotationFill);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_CMD_ANNOTATION_COPY:
                {
                    SVGAFifoCmdAnnotationCopy cmd;
                    uint32_t cmd_size = sizeof(SVGAFifoCmdAnnotationCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, false);
                    if (result == nullptr) return result;

                    break;
                }
            case SVGA_3D_CMD_SURFACE_DEFINE:
                {
                    SVGA3dCmdDefineSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;
                }

            case SVGA_3D_CMD_SURFACE_DEFINE_V2:
                {
                    SVGA3dCmdDefineSurface_v2 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineSurface_v2);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SURFACE_DESTROY:
                {
                    SVGA3dCmdDestroySurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroySurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SURFACE_COPY:
                {
                    SVGA3dCmdSurfaceCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSurfaceCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SURFACE_STRETCHBLT:
                {
                    SVGA3dCmdSurfaceStretchBlt cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSurfaceStretchBlt);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SURFACE_DMA:
                {
                    SVGA3dCmdSurfaceDMA cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSurfaceDMA);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN:
                {
                    SVGA3dCmdBlitSurfaceToScreen cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBlitSurfaceToScreen);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_CONTEXT_DEFINE:
                {
                    SVGA3dCmdDefineContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_CONTEXT_DESTROY:
                {
                    SVGA3dCmdDestroyContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroyContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETTRANSFORM:
                {
                    SVGA3dCmdSetTransform cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetTransform);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETZRANGE:
                {
                    SVGA3dCmdSetZRange cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetZRange);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETRENDERSTATE:
                {
                    SVGA3dCmdSetRenderState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetRenderState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETRENDERTARGET:
                {
                    SVGA3dCmdSetRenderTarget cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetRenderTarget);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETTEXTURESTATE:
                {
                    SVGA3dCmdSetTextureState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetTextureState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETMATERIAL:
                {
                    SVGA3dCmdSetMaterial cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetMaterial);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETLIGHTDATA:
                {
                    SVGA3dCmdSetLightData cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetLightData);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETLIGHTENABLED:
                {
                    SVGA3dCmdSetLightEnabled cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetLightEnabled);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETVIEWPORT:
                {
                    SVGA3dCmdSetViewport cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetViewport);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETCLIPPLANE:
                {
                    SVGA3dCmdSetClipPlane cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetClipPlane);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_CLEAR:
                {
                    SVGA3dCmdClear cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdClear);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_PRESENT:
            case SVGA_3D_CMD_PRESENT_READBACK: /** @todo SVGA_3D_CMD_PRESENT_READBACK isn't quite the same as present... */
                {
                    SVGA3dCmdPresent cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdPresent);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SHADER_DEFINE:
                {
                    SVGA3dCmdDefineShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SHADER_DESTROY:
                {
                    SVGA3dCmdDestroyShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroyShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SET_SHADER:
                {
                    SVGA3dCmdSetShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SET_SHADER_CONST:
                {
                    SVGA3dCmdSetShaderConst cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetShaderConst);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DRAW_PRIMITIVES:
                {
                    SVGA3dCmdDrawPrimitives cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDrawPrimitives);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SETSCISSORRECT:
                {
                    SVGA3dCmdSetScissorRect cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetScissorRect);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BEGIN_QUERY:
                {
                    SVGA3dCmdBeginQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBeginQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_END_QUERY:
                {
                    SVGA3dCmdEndQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdEndQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_WAIT_FOR_QUERY:
                {
                    SVGA3dCmdWaitForQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdWaitForQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_GENERATE_MIPMAPS:
                {
                    SVGA3dCmdGenerateMipmaps cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdGenerateMipmaps);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SCREEN_DMA:
                {
                    SVGA3dCmdScreenDMA cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdScreenDMA);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

                /* case SVGA_3D_CMD_DEAD1: New SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION */

            case SVGA_3D_CMD_SET_OTABLE_BASE:
                {
                    SVGA3dCmdSetOTableBase cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetOTableBase);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_READBACK_OTABLE:
                {
                    SVGA3dCmdReadbackOTable cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdReadbackOTable);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DEFINE_GB_MOB:
                {
                    SVGA3dCmdDefineGBMob cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBMob);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DESTROY_GB_MOB:
                {
                    SVGA3dCmdDestroyGBMob cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroyGBMob);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING:
                {
                    SVGA3dCmdUpdateGBMobMapping cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdUpdateGBMobMapping);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DEFINE_GB_SURFACE:
                {
                    SVGA3dCmdDefineGBSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DESTROY_GB_SURFACE:
                {
                    SVGA3dCmdDestroyGBSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroyGBSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BIND_GB_SURFACE:
                {
                    SVGA3dCmdBindGBSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBindGBSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_COND_BIND_GB_SURFACE:
                {
                    SVGA3dCmdCondBindGBSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdCondBindGBSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_UPDATE_GB_IMAGE:
                {
                    SVGA3dCmdUpdateGBImage cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdUpdateGBImage);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_UPDATE_GB_SURFACE:
                {
                    SVGA3dCmdUpdateGBSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdUpdateGBSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_READBACK_GB_IMAGE:
                {
                    SVGA3dCmdReadbackGBImage cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdReadbackGBImage);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_READBACK_GB_SURFACE:
                {
                    SVGA3dCmdReadbackGBSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdReadbackGBSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_INVALIDATE_GB_IMAGE:
                {
                    SVGA3dCmdInvalidateGBImage cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdInvalidateGBImage);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_INVALIDATE_GB_SURFACE:
                {
                    SVGA3dCmdInvalidateGBSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdInvalidateGBSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DEFINE_GB_CONTEXT:
                {
                    SVGA3dCmdDefineGBContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DESTROY_GB_CONTEXT:
                {
                    SVGA3dCmdDestroyGBContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroyGBContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BIND_GB_CONTEXT:
                {
                    SVGA3dCmdBindGBContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBindGBContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_READBACK_GB_CONTEXT:
                {
                    SVGA3dCmdReadbackGBContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdReadbackGBContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_INVALIDATE_GB_CONTEXT:
                {
                    SVGA3dCmdInvalidateGBContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdInvalidateGBContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DEFINE_GB_SHADER:
                {
                    SVGA3dCmdDefineGBShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DESTROY_GB_SHADER:
                {
                    SVGA3dCmdDestroyGBShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroyGBShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BIND_GB_SHADER:
                {
                    SVGA3dCmdBindGBShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBindGBShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SET_OTABLE_BASE64:
                {
                    SVGA3dCmdSetOTableBase64 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetOTableBase64);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BEGIN_GB_QUERY:
                {
                    SVGA3dCmdBeginGBQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBeginGBQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_END_GB_QUERY:
                {
                    SVGA3dCmdEndGBQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdEndGBQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_WAIT_FOR_GB_QUERY:
                {
                    SVGA3dCmdWaitForGBQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdWaitForGBQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_NOP:
                {
                    /* Apparently there is nothing to do. */
                    break;
                }

            case SVGA_3D_CMD_ENABLE_GART:
                {
                    SVGA3dCmdEnableGart cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdEnableGart);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_MAP_MOB_INTO_GART:
                {
                    SVGA3dCmdMapMobIntoGart cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdMapMobIntoGart);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_UNMAP_GART_RANGE:
                {
                    SVGA3dCmdUnmapGartRange cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdUnmapGartRange);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DEFINE_GB_SCREENTARGET:
                {
                    SVGA3dCmdDefineGBScreenTarget cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBScreenTarget);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DESTROY_GB_SCREENTARGET:
                {
                    SVGA3dCmdDestroyGBScreenTarget cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDestroyGBScreenTarget);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BIND_GB_SCREENTARGET:
                {
                    SVGA3dCmdBindGBScreenTarget cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBindGBScreenTarget);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_UPDATE_GB_SCREENTARGET:
                {
                    SVGA3dCmdUpdateGBScreenTarget cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdUpdateGBScreenTarget);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL:
                {
                    SVGA3dCmdReadbackGBImagePartial cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdReadbackGBImagePartial);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL:
                {
                    SVGA3dCmdInvalidateGBImagePartial cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdInvalidateGBImagePartial);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE:
                {
                    SVGA3dCmdSetGBShaderConstInline cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetGBShaderConstInline);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_GB_SCREEN_DMA:
                {
                    SVGA3dCmdGBScreenDMA cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdGBScreenDMA);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH:
                {
                    SVGA3dCmdBindGBSurfaceWithPitch cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdBindGBSurfaceWithPitch);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_GB_MOB_FENCE:
                {
                    SVGA3dCmdGBMobFence cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdGBMobFence);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DEFINE_GB_SURFACE_V2:
                {
                    SVGA3dCmdDefineGBSurface_v2 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBSurface_v2);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_DEFINE_GB_MOB64:
                {
                    SVGA3dCmdDefineGBMob64 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBMob64);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_REDEFINE_GB_MOB64:
                {
                    SVGA3dCmdRedefineGBMob64 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdRedefineGBMob64);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_NOP_ERROR:
                {
                    /* Apparently there is nothing to do. */
                    break;
                }

            case SVGA_3D_CMD_SET_VERTEX_STREAMS:
                {
                    SVGA3dCmdSetVertexStreams cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetVertexStreams);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SET_VERTEX_DECLS:
                {
                    SVGA3dCmdSetVertexDecls cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetVertexDecls);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }

            case SVGA_3D_CMD_SET_VERTEX_DIVISORS:
                {
                    SVGA3dCmdSetVertexDivisors cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSetVertexDivisors);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;

                    break;

                }
            case SVGA_3D_CMD_DX_DEFINE_CONTEXT:
                {
                    SVGA3dCmdDXDefineContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_CONTEXT:
                {
                    SVGA3dCmdDXDestroyContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BIND_CONTEXT:
                {
                    SVGA3dCmdDXBindContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBindContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_READBACK_CONTEXT:
                {
                    SVGA3dCmdDXReadbackContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXReadbackContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_INVALIDATE_CONTEXT:
                {
                    SVGA3dCmdDXInvalidateContext cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXInvalidateContext);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER:
                {
                    SVGA3dCmdDXSetSingleConstantBuffer cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetSingleConstantBuffer);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_SHADER_RESOURCES:
                {
                    SVGA3dCmdDXSetShaderResources cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetShaderResources);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_SHADER:
                {
                    SVGA3dCmdDXSetShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_SAMPLERS:
                {
                    SVGA3dCmdDXSetSamplers cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetSamplers);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DRAW:
                {
                    SVGA3dCmdDXDraw cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDraw);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DRAW_INDEXED:
                {
                    SVGA3dCmdDXDrawIndexed cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDrawIndexed);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DRAW_INSTANCED:
                {
                    SVGA3dCmdDXDrawInstanced cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDrawInstanced);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED:
                {
                    SVGA3dCmdDXDrawIndexedInstanced cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDrawIndexedInstanced);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DRAW_AUTO:
                {
                    SVGA3dCmdDXDrawAuto cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDrawAuto);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_INPUT_LAYOUT:
                {
                    SVGA3dCmdDXSetInputLayout cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetInputLayout);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS:
                {
                    SVGA3dCmdDXSetVertexBuffers cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetVertexBuffers);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_INDEX_BUFFER:
                {
                    SVGA3dCmdDXSetIndexBuffer cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetIndexBuffer);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_TOPOLOGY:
                {
                    SVGA3dCmdDXSetTopology cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetTopology);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_RENDERTARGETS:
                {
                    SVGA3dCmdDXSetRenderTargets cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetRenderTargets);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_BLEND_STATE:
                {
                    SVGA3dCmdDXSetBlendState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetBlendState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_DEPTHSTENCIL_STATE:
                {
                    SVGA3dCmdDXSetDepthStencilState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetDepthStencilState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_RASTERIZER_STATE:
                {
                    SVGA3dCmdDXSetRasterizerState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetRasterizerState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_QUERY:
                {
                    SVGA3dCmdDXDefineQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_QUERY:
                {
                    SVGA3dCmdDXDestroyQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BIND_QUERY:
                {
                    SVGA3dCmdDXBindQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBindQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_QUERY_OFFSET:
                {
                    SVGA3dCmdDXSetQueryOffset cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetQueryOffset);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BEGIN_QUERY:
                {
                    SVGA3dCmdDXBeginQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBeginQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_END_QUERY:
                {
                    SVGA3dCmdDXEndQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXEndQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_READBACK_QUERY:
                {
                    SVGA3dCmdDXReadbackQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXReadbackQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_PREDICATION:
                {
                    SVGA3dCmdDXSetPredication cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetPredication);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_SOTARGETS:
                {
                    SVGA3dCmdDXSetSOTargets cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetSOTargets);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_VIEWPORTS:
                {
                    SVGA3dCmdDXSetViewports cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetViewports);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_SCISSORRECTS:
                {
                    SVGA3dCmdDXSetScissorRects cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetScissorRects);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_CLEAR_RENDERTARGET_VIEW:
                {
                    SVGA3dCmdDXClearRenderTargetView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXClearRenderTargetView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_CLEAR_DEPTHSTENCIL_VIEW:
                {
                    SVGA3dCmdDXClearDepthStencilView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXClearDepthStencilView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_PRED_COPY_REGION:
                {
                    SVGA3dCmdDXPredCopyRegion cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXPredCopyRegion);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_PRED_COPY:
                {
                    SVGA3dCmdDXPredCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXPredCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_PRESENTBLT:
                {
                    SVGA3dCmdDXPresentBlt cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXPresentBlt);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_GENMIPS:
                {
                    SVGA3dCmdDXGenMips cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXGenMips);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE:
                {
                    SVGA3dCmdDXUpdateSubResource cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXUpdateSubResource);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_READBACK_SUBRESOURCE:
                {
                    SVGA3dCmdDXReadbackSubResource cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXReadbackSubResource);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE:
                {
                    SVGA3dCmdDXInvalidateSubResource cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXInvalidateSubResource);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW:
                {
                    SVGA3dCmdDXDefineShaderResourceView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineShaderResourceView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_SHADERRESOURCE_VIEW:
                {
                    SVGA3dCmdDXDestroyShaderResourceView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyShaderResourceView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW:
                {
                    SVGA3dCmdDXDefineRenderTargetView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineRenderTargetView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_RENDERTARGET_VIEW:
                {
                    SVGA3dCmdDXDestroyRenderTargetView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyRenderTargetView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW:
                {
                    SVGA3dCmdDXDefineDepthStencilView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineDepthStencilView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_VIEW:
                {
                    SVGA3dCmdDXDestroyDepthStencilView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyDepthStencilView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_ELEMENTLAYOUT:
                {
                    SVGA3dCmdDXDefineElementLayout cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineElementLayout);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_ELEMENTLAYOUT:
                {
                    SVGA3dCmdDXDestroyElementLayout cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyElementLayout);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_BLEND_STATE:
                {
                    SVGA3dCmdDXDefineBlendState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineBlendState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_BLEND_STATE:
                {
                    SVGA3dCmdDXDestroyBlendState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyBlendState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_STATE:
                {
                    SVGA3dCmdDXDefineDepthStencilState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineDepthStencilState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_DEPTHSTENCIL_STATE:
                {
                    SVGA3dCmdDXDestroyDepthStencilState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyDepthStencilState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE:
                {
                    SVGA3dCmdDXDefineRasterizerState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineRasterizerState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_RASTERIZER_STATE:
                {
                    SVGA3dCmdDXDestroyRasterizerState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyRasterizerState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_SAMPLER_STATE:
                {
                    SVGA3dCmdDXDefineSamplerState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineSamplerState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_SAMPLER_STATE:
                {
                    SVGA3dCmdDXDestroySamplerState cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroySamplerState);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_SHADER:
                {
                    SVGA3dCmdDXDefineShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_SHADER:
                {
                    SVGA3dCmdDXDestroyShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BIND_SHADER:
                {
                    SVGA3dCmdDXBindShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBindShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT:
                {
                    SVGA3dCmdDXDefineStreamOutput cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineStreamOutput);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_STREAMOUTPUT:
                {
                    SVGA3dCmdDXDestroyStreamOutput cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyStreamOutput);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_STREAMOUTPUT:
                {
                    SVGA3dCmdDXSetStreamOutput cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetStreamOutput);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_COTABLE:
                {
                    SVGA3dCmdDXSetCOTable cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetCOTable);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_READBACK_COTABLE:
                {
                    SVGA3dCmdDXReadbackCOTable cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXReadbackCOTable);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BUFFER_COPY:
                {
                    SVGA3dCmdDXBufferCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBufferCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER:
                {
                    SVGA3dCmdDXTransferFromBuffer cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXTransferFromBuffer);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SURFACE_COPY_AND_READBACK:
                {
                    SVGA3dCmdDXSurfaceCopyAndReadback cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSurfaceCopyAndReadback);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_MOVE_QUERY:
                {
                    SVGA3dCmdDXMoveQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXMoveQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BIND_ALL_QUERY:
                {
                    SVGA3dCmdDXBindAllQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBindAllQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_READBACK_ALL_QUERY:
                {
                    SVGA3dCmdDXReadbackAllQuery cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXReadbackAllQuery);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_PRED_TRANSFER_FROM_BUFFER:
                {
                    SVGA3dCmdDXPredTransferFromBuffer cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXPredTransferFromBuffer);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_MOB_FENCE_64:
                {
                    SVGA3dCmdDXMobFence64 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXMobFence64);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BIND_ALL_SHADER:
                {
                    SVGA3dCmdDXBindAllShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBindAllShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_HINT:
                {
                    SVGA3dCmdDXHint cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXHint);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BUFFER_UPDATE:
                {
                    SVGA3dCmdDXBufferUpdate cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBufferUpdate);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_VS_CONSTANT_BUFFER_OFFSET:
                {
                    SVGA3dCmdDXSetVSConstantBufferOffset cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetVSConstantBufferOffset);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_PS_CONSTANT_BUFFER_OFFSET:
                {
                    SVGA3dCmdDXSetPSConstantBufferOffset cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetPSConstantBufferOffset);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_GS_CONSTANT_BUFFER_OFFSET:
                {
                    SVGA3dCmdDXSetGSConstantBufferOffset cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetGSConstantBufferOffset);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_HS_CONSTANT_BUFFER_OFFSET:
                {
                    SVGA3dCmdDXSetHSConstantBufferOffset cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetHSConstantBufferOffset);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_DS_CONSTANT_BUFFER_OFFSET:
                {
                    SVGA3dCmdDXSetDSConstantBufferOffset cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetDSConstantBufferOffset);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_CS_CONSTANT_BUFFER_OFFSET:
                {
                    SVGA3dCmdDXSetCSConstantBufferOffset cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetCSConstantBufferOffset);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_COND_BIND_ALL_SHADER:
                {
                    SVGA3dCmdDXCondBindAllShader cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXCondBindAllShader);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_SCREEN_COPY:
                {
                    SVGA3dCmdScreenCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdScreenCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_RESERVED1:
                {
                    break;
                }

            case SVGA_3D_CMD_RESERVED2:
                {
                    break;
                }

            case SVGA_3D_CMD_RESERVED3:
                {
                    
                    break;
                }

            case SVGA_3D_CMD_RESERVED4:
                {
                    
                    break;
                }

            case SVGA_3D_CMD_RESERVED5:
                {
                    
                    break;
                }

            case SVGA_3D_CMD_RESERVED6:
                {
                    
                    break;
                }

            case SVGA_3D_CMD_RESERVED7:
                {
                    
                    break;
                }

            case SVGA_3D_CMD_RESERVED8:
                {
                    
                    break;
                }

            case SVGA_3D_CMD_GROW_OTABLE:
                {
                    SVGA3dCmdGrowOTable cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdGrowOTable);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_GROW_COTABLE:
                {
                    SVGA3dCmdDXGrowCOTable cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXGrowCOTable);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_INTRA_SURFACE_COPY:
                {
                    SVGA3dCmdIntraSurfaceCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdIntraSurfaceCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DEFINE_GB_SURFACE_V3:
                {
                    SVGA3dCmdDefineGBSurface_v3 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBSurface_v3);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_RESOLVE_COPY:
                {
                    SVGA3dCmdDXResolveCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXResolveCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_PRED_RESOLVE_COPY:
                {
                    SVGA3dCmdDXPredResolveCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXPredResolveCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_PRED_CONVERT_REGION:
                {
                    SVGA3dCmdDXPredConvertRegion cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXPredConvertRegion);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_PRED_CONVERT:
                {
                    SVGA3dCmdDXPredConvert cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXPredConvert);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_WHOLE_SURFACE_COPY:
                {
                    SVGA3dCmdWholeSurfaceCopy cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdWholeSurfaceCopy);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_UA_VIEW:
                {
                    SVGA3dCmdDXDefineUAView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineUAView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DESTROY_UA_VIEW:
                {
                    SVGA3dCmdDXDestroyUAView cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDestroyUAView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_CLEAR_UA_VIEW_UINT:
                {
                    SVGA3dCmdDXClearUAViewUint cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXClearUAViewUint);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_CLEAR_UA_VIEW_FLOAT:
                {
                    SVGA3dCmdDXClearUAViewFloat cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXClearUAViewFloat);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_COPY_STRUCTURE_COUNT:
                {
                    SVGA3dCmdDXCopyStructureCount cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXCopyStructureCount);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_UA_VIEWS:
                {
                    SVGA3dCmdDXSetUAViews cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetUAViews);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT:
                {
                    SVGA3dCmdDXDrawIndexedInstancedIndirect cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDrawIndexedInstancedIndirect);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT:
                {
                    SVGA3dCmdDXDrawInstancedIndirect cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDrawInstancedIndirect);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DISPATCH:
                {
                    SVGA3dCmdDXDispatch cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDispatch);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DISPATCH_INDIRECT:
                {
                    SVGA3dCmdDXDispatchIndirect cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDispatchIndirect);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_WRITE_ZERO_SURFACE:
                {
                    SVGA3dCmdWriteZeroSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdWriteZeroSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_HINT_ZERO_SURFACE:
                {
                    SVGA3dCmdHintZeroSurface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdHintZeroSurface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_TRANSFER_TO_BUFFER:
                {
                    SVGA3dCmdDXTransferToBuffer cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXTransferToBuffer);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_STRUCTURE_COUNT:
                {
                    SVGA3dCmdDXSetStructureCount cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetStructureCount);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_LOGICOPS_BITBLT:
                {
                    SVGA3dCmdLogicOpsBitBlt cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdLogicOpsBitBlt);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_LOGICOPS_TRANSBLT:
                {
                    SVGA3dCmdLogicOpsTransBlt cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdLogicOpsTransBlt);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_LOGICOPS_STRETCHBLT:
                {
                    SVGA3dCmdLogicOpsStretchBlt cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdLogicOpsStretchBlt);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_LOGICOPS_COLORFILL:
                {
                    SVGA3dCmdLogicOpsColorFill cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdLogicOpsColorFill);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_LOGICOPS_ALPHABLEND:
                {
                    SVGA3dCmdLogicOpsAlphaBlend cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdLogicOpsAlphaBlend);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND:
                {
                    SVGA3dCmdLogicOpsClearTypeBlend cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdLogicOpsClearTypeBlend);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_RESERVED2_1:
                {
                    
                    break;
                }

            case SVGA_3D_CMD_RESERVED2_2:
                {
                    break;
                }

            case SVGA_3D_CMD_DEFINE_GB_SURFACE_V4:
                {
                    SVGA3dCmdDefineGBSurface_v4 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDefineGBSurface_v4);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_CS_UA_VIEWS:
                {
                    SVGA3dCmdDXSetCSUAViews cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetCSUAViews);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_MIN_LOD:
                {
                    SVGA3dCmdDXSetMinLOD cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetMinLOD);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_RESERVED2_3:
                {
                    break;
                }

            case SVGA_3D_CMD_RESERVED2_4:
                {
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2:
                {
                    SVGA3dCmdDXDefineDepthStencilView_v2 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineDepthStencilView_v2);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_STREAMOUTPUT_WITH_MOB:
                {
                    SVGA3dCmdDXDefineStreamOutputWithMob cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineStreamOutputWithMob);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_SET_SHADER_IFACE:
                {
                    SVGA3dCmdDXSetShaderIface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXSetShaderIface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BIND_STREAMOUTPUT:
                {
                    SVGA3dCmdDXBindStreamOutput cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBindStreamOutput);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_SURFACE_STRETCHBLT_NON_MS_TO_MS:
                {
                    SVGA3dCmdSurfaceStretchBltNonMSToMS cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdSurfaceStretchBltNonMSToMS);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_BIND_SHADER_IFACE:
                {
                    SVGA3dCmdDXBindShaderIface cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXBindShaderIface);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_VB_DX_CLEAR_RENDERTARGET_VIEW_REGION:
                {
                    SVGA3dCmdVBDXClearRenderTargetViewRegion cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdVBDXClearRenderTargetViewRegion);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case SVGA_3D_CMD_DX_DEFINE_RASTERIZER_STATE_V2:
                {
                    SVGA3dCmdDXDefineRasterizerState_v2 cmd;
                    uint32_t cmd_size = sizeof(SVGA3dCmdDXDefineRasterizerState_v2);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR:
                {
                    VBSVGA3dCmdDXDefineVideoProcessor cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDefineVideoProcessor);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER_OUTPUT_VIEW:
                {
                    VBSVGA3dCmdDXDefineVideoDecoderOutputView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDefineVideoDecoderOutputView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DEFINE_VIDEO_DECODER:
                {
                    VBSVGA3dCmdDXDefineVideoDecoder cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDefineVideoDecoder);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_DECODER_BEGIN_FRAME:
                {
                    VBSVGA3dCmdDXVideoDecoderBeginFrame cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoDecoderBeginFrame);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_DECODER_SUBMIT_BUFFERS:
                {
                    VBSVGA3dCmdDXVideoDecoderSubmitBuffers cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoDecoderSubmitBuffers);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_DECODER_END_FRAME:
                {
                    VBSVGA3dCmdDXVideoDecoderEndFrame cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoDecoderEndFrame);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_INPUT_VIEW:
                {
                    VBSVGA3dCmdDXDefineVideoProcessorInputView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDefineVideoProcessorInputView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DEFINE_VIDEO_PROCESSOR_OUTPUT_VIEW:
                {
                    VBSVGA3dCmdDXDefineVideoProcessorOutputView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDefineVideoProcessorOutputView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_BLT:
                {
                    VBSVGA3dCmdDXVideoProcessorBlt cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorBlt);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER:
                {
                    VBSVGA3dCmdDXDestroyVideoDecoder cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDestroyVideoDecoder);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DESTROY_VIDEO_DECODER_OUTPUT_VIEW:
                {
                    VBSVGA3dCmdDXDestroyVideoDecoderOutputView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDestroyVideoDecoderOutputView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR:
                {
                    VBSVGA3dCmdDXDestroyVideoProcessor cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDestroyVideoProcessor);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_INPUT_VIEW:
                {
                    VBSVGA3dCmdDXDestroyVideoProcessorInputView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDestroyVideoProcessorInputView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_DESTROY_VIDEO_PROCESSOR_OUTPUT_VIEW:
                {
                    VBSVGA3dCmdDXDestroyVideoProcessorOutputView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXDestroyVideoProcessorOutputView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_TARGET_RECT:
                {
                    VBSVGA3dCmdDXVideoProcessorSetOutputTargetRect cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetOutputTargetRect);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_BACKGROUND_COLOR:
                {
                    VBSVGA3dCmdDXVideoProcessorSetOutputBackgroundColor cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetOutputBackgroundColor);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_COLOR_SPACE:
                {
                    VBSVGA3dCmdDXVideoProcessorSetOutputColorSpace cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetOutputColorSpace);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_ALPHA_FILL_MODE:
                {
                    VBSVGA3dCmdDXVideoProcessorSetOutputAlphaFillMode cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetOutputAlphaFillMode);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_CONSTRICTION:
                {
                    VBSVGA3dCmdDXVideoProcessorSetOutputConstriction cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetOutputConstriction);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_OUTPUT_STEREO_MODE:
                {
                    VBSVGA3dCmdDXVideoProcessorSetOutputStereoMode cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetOutputStereoMode);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FRAME_FORMAT:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamFrameFormat cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamFrameFormat);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_COLOR_SPACE:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamColorSpace cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamColorSpace);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_OUTPUT_RATE:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamOutputRate cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamOutputRate);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_SOURCE_RECT:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamSourceRect cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamSourceRect);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_DEST_RECT:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamDestRect cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamDestRect);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ALPHA:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamAlpha cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamAlpha);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PALETTE:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamPalette cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamPalette);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_PIXEL_ASPECT_RATIO:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamPixelAspectRatio cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamPixelAspectRatio);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_LUMA_KEY:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamLumaKey cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamLumaKey);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_STEREO_FORMAT:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamStereoFormat cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamStereoFormat);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_AUTO_PROCESSING_MODE:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamAutoProcessingMode cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamAutoProcessingMode);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_FILTER:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamFilter cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamFilter);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_VIDEO_PROCESSOR_SET_STREAM_ROTATION:
                {
                    VBSVGA3dCmdDXVideoProcessorSetStreamRotation cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXVideoProcessorSetStreamRotation);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_GET_VIDEO_CAPABILITY:
                {
                    VBSVGA3dCmdDXGetVideoCapability cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXGetVideoCapability);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_CLEAR_RTV:
                {
                    VBSVGA3dCmdDXClearView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXClearView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_CLEAR_UAV:
                {
                    VBSVGA3dCmdDXClearView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXClearView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_CLEAR_VDOV:
                {
                    VBSVGA3dCmdDXClearView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXClearView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_CLEAR_VPIV:
                {
                    VBSVGA3dCmdDXClearView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXClearView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }

            case VBSVGA_3D_CMD_DX_CLEAR_VPOV:
                {
                    VBSVGA3dCmdDXClearView cmd;
                    uint32_t cmd_size = sizeof(VBSVGA3dCmdDXClearView);
                    result = InternalCommandAlloc(fdp, total_length, pos, result, &cmd, cmd_size, cmdId, true);
                    if (result == nullptr) return result;
                    break;
                }
            default: 
                continue;

        }
    }
    commands_length = total_length;
    return result;
}
